A collection is a group of data items that are to be operated on together. Some examples of collections include lists, arrays, sets, bags, and various other groupings of data. In the early days of programming, programs were typically monolithic entities that did not interoperate with each other. Thus, programs were able to manage collections internally in whatever manner the programmer chose. In modern programming, however, it has become a more prevalent practice for different instances of the same program, or different programs, to interoperate with each other by manipulating a shared set of data.
While it is possible for programs to implement their own mechanisms for sharing data, doing so is generally cumbersome for the programmer. The programmer may have to implement the sharing mechanism as a tightly integrated part of the program. Even if the programmer can obtain the code for an existing sharing mechanism, the mechanism is often specific to the nature of the program and to the type of data that is being shared. And, when other programs want to share data with an existing program, those programs have to be implemented in such a way such that the same sharing mechanism is used.
While allowing programs to share data presents various issues, the sharing of collections presents additional issues. For many types of collections, the current state of the collection is defined not only by the contents of the collection, but also by the order in which those contents appear. For example, the array {1,2,3,4,5} is different from the array {2,3,1,5,4}. Even though those two arrays contain the same underlying elements (the numbers one through five), the order is different, and thus these two arrays have different states. Maintaining the state of a collection, particularly the ordering, presents certain challenges when the state of a collection may be changed by several programs.